//
//  CarDetailObj.m
//
//  Created by lizhenqiang  on 15/8/9
//  Copyright (c) 2015 __MyCompanyName__. All rights reserved.
//

#import "CarDetailObj.h"


NSString *const kCarDetailObjId = @"id";
NSString *const kCarDetailObjGearType = @"gearType";
NSString *const kCarDetailObjDrivingLicenseTag = @"drivingLicenseTag";
NSString *const kCarDetailObjTripod = @"tripod";
NSString *const kCarDetailObjFacEqu = @"facEqu";
NSString *const kCarDetailObjMaintenanceManual = @"maintenanceManual";
NSString *const kCarDetailObjEnvTag = @"envTag";
NSString *const kCarDetailObjPassengerNum = @"passengerNum";
NSString *const kCarDetailObjCarColor = @"carColor";
NSString *const kCarDetailObjInstruction = @"instruction";
NSString *const kCarDetailObjOutputVolume = @"outputVolume";
NSString *const kCarDetailObjIssurFee = @"issurFee";
NSString *const kCarDetailObjSpareTire = @"spareTire";
NSString *const kCarDetailObjRegistMonth = @"registMonth";
NSString *const kCarDetailObjMarketDesc = @"marketDesc";
NSString *const kCarDetailObjLicenseTag = @"licenseTag";
NSString *const kCarDetailObjLicenseCode = @"licenseCode";
NSString *const kCarDetailObjCheckValidDate = @"checkValidDate";
NSString *const kCarDetailObjUpholsteryColor = @"upholsteryColor";
NSString *const kCarDetailObjCd = @"cd";
NSString *const kCarDetailObjCarKeys = @"carKeys";
NSString *const kCarDetailObjIssurValidDate = @"issurValidDate";
NSString *const kCarDetailObjCusEqu = @"cusEqu";
NSString *const kCarDetailObjFactoryDate = @"factoryDate";
NSString *const kCarDetailObjVehicleType = @"vehicleType";
NSString *const kCarDetailObjRegistNum = @"registNum";
NSString *const kCarDetailObjMileageCount = @"mileageCount";
NSString *const kCarDetailObjRegistTag = @"registTag";
NSString *const kCarDetailObjPurchaseTag = @"purchaseTag";
NSString *const kCarDetailObjMaintenanceMile = @"maintenanceMile";
NSString *const kCarDetailObjInvoiceTag = @"invoiceTag";
NSString *const kCarDetailObjUsedType = @"usedType";
NSString *const kCarDetailObjTransferNum = @"transferNum";
NSString *const kCarDetailObjEngineNum = @"engineNum";
NSString *const kCarDetailObjNavigationCard = @"navigationCard";
NSString *const kCarDetailObjEnvLevel = @"envLevel";
NSString *const kCarDetailObjIssurLevel = @"issurLevel";


@interface CarDetailObj ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation CarDetailObj

@synthesize internalBaseClassIdentifier = _internalBaseClassIdentifier;
@synthesize gearType = _gearType;
@synthesize drivingLicenseTag = _drivingLicenseTag;
@synthesize tripod = _tripod;
@synthesize facEqu = _facEqu;
@synthesize maintenanceManual = _maintenanceManual;
@synthesize envTag = _envTag;
@synthesize passengerNum = _passengerNum;
@synthesize carColor = _carColor;
@synthesize instruction = _instruction;
@synthesize outputVolume = _outputVolume;
@synthesize issurFee = _issurFee;
@synthesize spareTire = _spareTire;
@synthesize registMonth = _registMonth;
@synthesize marketDesc = _marketDesc;
@synthesize licenseTag = _licenseTag;
@synthesize licenseCode = _licenseCode;
@synthesize checkValidDate = _checkValidDate;
@synthesize upholsteryColor = _upholsteryColor;
@synthesize cd = _cd;
@synthesize carKeys = _carKeys;
@synthesize issurValidDate = _issurValidDate;
@synthesize cusEqu = _cusEqu;
@synthesize factoryDate = _factoryDate;
@synthesize vehicleType = _vehicleType;
@synthesize registNum = _registNum;
@synthesize mileageCount = _mileageCount;
@synthesize registTag = _registTag;
@synthesize purchaseTag = _purchaseTag;
@synthesize maintenanceMile = _maintenanceMile;
@synthesize invoiceTag = _invoiceTag;
@synthesize usedType = _usedType;
@synthesize transferNum = _transferNum;
@synthesize engineNum = _engineNum;
@synthesize navigationCard = _navigationCard;
@synthesize envLevel = _envLevel;
@synthesize issurLevel = _issurLevel;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.internalBaseClassIdentifier = [[self objectOrNilForKey:kCarDetailObjId fromDictionary:dict] doubleValue];
            self.gearType = [self objectOrNilForKey:kCarDetailObjGearType fromDictionary:dict];
            self.drivingLicenseTag = [self objectOrNilForKey:kCarDetailObjDrivingLicenseTag fromDictionary:dict];
            self.tripod = [self objectOrNilForKey:kCarDetailObjTripod fromDictionary:dict];
            self.facEqu = [self objectOrNilForKey:kCarDetailObjFacEqu fromDictionary:dict];
            self.maintenanceManual = [self objectOrNilForKey:kCarDetailObjMaintenanceManual fromDictionary:dict];
            self.envTag = [self objectOrNilForKey:kCarDetailObjEnvTag fromDictionary:dict];
            self.passengerNum = [self objectOrNilForKey:kCarDetailObjPassengerNum fromDictionary:dict];
            self.carColor = [self objectOrNilForKey:kCarDetailObjCarColor fromDictionary:dict];
            self.instruction = [self objectOrNilForKey:kCarDetailObjInstruction fromDictionary:dict];
            self.outputVolume = [self objectOrNilForKey:kCarDetailObjOutputVolume fromDictionary:dict];
            self.issurFee = [self objectOrNilForKey:kCarDetailObjIssurFee fromDictionary:dict];
            self.spareTire = [self objectOrNilForKey:kCarDetailObjSpareTire fromDictionary:dict];
            self.registMonth = [self objectOrNilForKey:kCarDetailObjRegistMonth fromDictionary:dict];
            self.marketDesc = [self objectOrNilForKey:kCarDetailObjMarketDesc fromDictionary:dict];
            self.licenseTag = [self objectOrNilForKey:kCarDetailObjLicenseTag fromDictionary:dict];
            self.licenseCode = [self objectOrNilForKey:kCarDetailObjLicenseCode fromDictionary:dict];
            self.checkValidDate = [self objectOrNilForKey:kCarDetailObjCheckValidDate fromDictionary:dict];
            self.upholsteryColor = [self objectOrNilForKey:kCarDetailObjUpholsteryColor fromDictionary:dict];
            self.cd = [self objectOrNilForKey:kCarDetailObjCd fromDictionary:dict];
            self.carKeys = [self objectOrNilForKey:kCarDetailObjCarKeys fromDictionary:dict];
            self.issurValidDate = [self objectOrNilForKey:kCarDetailObjIssurValidDate fromDictionary:dict];
            self.cusEqu = [self objectOrNilForKey:kCarDetailObjCusEqu fromDictionary:dict];
            self.factoryDate = [self objectOrNilForKey:kCarDetailObjFactoryDate fromDictionary:dict];
            self.vehicleType = [self objectOrNilForKey:kCarDetailObjVehicleType fromDictionary:dict];
            self.registNum = [self objectOrNilForKey:kCarDetailObjRegistNum fromDictionary:dict];
            self.mileageCount = [self objectOrNilForKey:kCarDetailObjMileageCount fromDictionary:dict];
            self.registTag = [self objectOrNilForKey:kCarDetailObjRegistTag fromDictionary:dict];
            self.purchaseTag = [self objectOrNilForKey:kCarDetailObjPurchaseTag fromDictionary:dict];
            self.maintenanceMile = [self objectOrNilForKey:kCarDetailObjMaintenanceMile fromDictionary:dict];
            self.invoiceTag = [self objectOrNilForKey:kCarDetailObjInvoiceTag fromDictionary:dict];
            self.usedType = [self objectOrNilForKey:kCarDetailObjUsedType fromDictionary:dict];
            self.transferNum = [self objectOrNilForKey:kCarDetailObjTransferNum fromDictionary:dict];
            self.engineNum = [self objectOrNilForKey:kCarDetailObjEngineNum fromDictionary:dict];
            self.navigationCard = [self objectOrNilForKey:kCarDetailObjNavigationCard fromDictionary:dict];
            self.envLevel = [self objectOrNilForKey:kCarDetailObjEnvLevel fromDictionary:dict];
            self.issurLevel = [self objectOrNilForKey:kCarDetailObjIssurLevel fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:[NSNumber numberWithDouble:self.internalBaseClassIdentifier] forKey:kCarDetailObjId];
    [mutableDict setValue:self.gearType forKey:kCarDetailObjGearType];
    [mutableDict setValue:self.drivingLicenseTag forKey:kCarDetailObjDrivingLicenseTag];
    [mutableDict setValue:self.tripod forKey:kCarDetailObjTripod];
    [mutableDict setValue:self.facEqu forKey:kCarDetailObjFacEqu];
    [mutableDict setValue:self.maintenanceManual forKey:kCarDetailObjMaintenanceManual];
    [mutableDict setValue:self.envTag forKey:kCarDetailObjEnvTag];
    [mutableDict setValue:self.passengerNum forKey:kCarDetailObjPassengerNum];
    [mutableDict setValue:self.carColor forKey:kCarDetailObjCarColor];
    [mutableDict setValue:self.instruction forKey:kCarDetailObjInstruction];
    [mutableDict setValue:self.outputVolume forKey:kCarDetailObjOutputVolume];
    [mutableDict setValue:self.issurFee forKey:kCarDetailObjIssurFee];
    [mutableDict setValue:self.spareTire forKey:kCarDetailObjSpareTire];
    [mutableDict setValue:self.registMonth forKey:kCarDetailObjRegistMonth];
    [mutableDict setValue:self.marketDesc forKey:kCarDetailObjMarketDesc];
    [mutableDict setValue:self.licenseTag forKey:kCarDetailObjLicenseTag];
    [mutableDict setValue:self.licenseCode forKey:kCarDetailObjLicenseCode];
    [mutableDict setValue:self.checkValidDate forKey:kCarDetailObjCheckValidDate];
    [mutableDict setValue:self.upholsteryColor forKey:kCarDetailObjUpholsteryColor];
    [mutableDict setValue:self.cd forKey:kCarDetailObjCd];
    [mutableDict setValue:self.carKeys forKey:kCarDetailObjCarKeys];
    [mutableDict setValue:self.issurValidDate forKey:kCarDetailObjIssurValidDate];
    [mutableDict setValue:self.cusEqu forKey:kCarDetailObjCusEqu];
    [mutableDict setValue:self.factoryDate forKey:kCarDetailObjFactoryDate];
    [mutableDict setValue:self.vehicleType forKey:kCarDetailObjVehicleType];
    [mutableDict setValue:self.registNum forKey:kCarDetailObjRegistNum];
    [mutableDict setValue:self.mileageCount forKey:kCarDetailObjMileageCount];
    [mutableDict setValue:self.registTag forKey:kCarDetailObjRegistTag];
    [mutableDict setValue:self.purchaseTag forKey:kCarDetailObjPurchaseTag];
    [mutableDict setValue:self.maintenanceMile forKey:kCarDetailObjMaintenanceMile];
    [mutableDict setValue:self.invoiceTag forKey:kCarDetailObjInvoiceTag];
    [mutableDict setValue:self.usedType forKey:kCarDetailObjUsedType];
    [mutableDict setValue:self.transferNum forKey:kCarDetailObjTransferNum];
    [mutableDict setValue:self.engineNum forKey:kCarDetailObjEngineNum];
    [mutableDict setValue:self.navigationCard forKey:kCarDetailObjNavigationCard];
    [mutableDict setValue:self.envLevel forKey:kCarDetailObjEnvLevel];
    [mutableDict setValue:self.issurLevel forKey:kCarDetailObjIssurLevel];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.internalBaseClassIdentifier = [aDecoder decodeDoubleForKey:kCarDetailObjId];
    self.gearType = [aDecoder decodeObjectForKey:kCarDetailObjGearType];
    self.drivingLicenseTag = [aDecoder decodeObjectForKey:kCarDetailObjDrivingLicenseTag];
    self.tripod = [aDecoder decodeObjectForKey:kCarDetailObjTripod];
    self.facEqu = [aDecoder decodeObjectForKey:kCarDetailObjFacEqu];
    self.maintenanceManual = [aDecoder decodeObjectForKey:kCarDetailObjMaintenanceManual];
    self.envTag = [aDecoder decodeObjectForKey:kCarDetailObjEnvTag];
    self.passengerNum = [aDecoder decodeObjectForKey:kCarDetailObjPassengerNum];
    self.carColor = [aDecoder decodeObjectForKey:kCarDetailObjCarColor];
    self.instruction = [aDecoder decodeObjectForKey:kCarDetailObjInstruction];
    self.outputVolume = [aDecoder decodeObjectForKey:kCarDetailObjOutputVolume];
    self.issurFee = [aDecoder decodeObjectForKey:kCarDetailObjIssurFee];
    self.spareTire = [aDecoder decodeObjectForKey:kCarDetailObjSpareTire];
    self.registMonth = [aDecoder decodeObjectForKey:kCarDetailObjRegistMonth];
    self.marketDesc = [aDecoder decodeObjectForKey:kCarDetailObjMarketDesc];
    self.licenseTag = [aDecoder decodeObjectForKey:kCarDetailObjLicenseTag];
    self.licenseCode = [aDecoder decodeObjectForKey:kCarDetailObjLicenseCode];
    self.checkValidDate = [aDecoder decodeObjectForKey:kCarDetailObjCheckValidDate];
    self.upholsteryColor = [aDecoder decodeObjectForKey:kCarDetailObjUpholsteryColor];
    self.cd = [aDecoder decodeObjectForKey:kCarDetailObjCd];
    self.carKeys = [aDecoder decodeObjectForKey:kCarDetailObjCarKeys];
    self.issurValidDate = [aDecoder decodeObjectForKey:kCarDetailObjIssurValidDate];
    self.cusEqu = [aDecoder decodeObjectForKey:kCarDetailObjCusEqu];
    self.factoryDate = [aDecoder decodeObjectForKey:kCarDetailObjFactoryDate];
    self.vehicleType = [aDecoder decodeObjectForKey:kCarDetailObjVehicleType];
    self.registNum = [aDecoder decodeObjectForKey:kCarDetailObjRegistNum];
    self.mileageCount = [aDecoder decodeObjectForKey:kCarDetailObjMileageCount];
    self.registTag = [aDecoder decodeObjectForKey:kCarDetailObjRegistTag];
    self.purchaseTag = [aDecoder decodeObjectForKey:kCarDetailObjPurchaseTag];
    self.maintenanceMile = [aDecoder decodeObjectForKey:kCarDetailObjMaintenanceMile];
    self.invoiceTag = [aDecoder decodeObjectForKey:kCarDetailObjInvoiceTag];
    self.usedType = [aDecoder decodeObjectForKey:kCarDetailObjUsedType];
    self.transferNum = [aDecoder decodeObjectForKey:kCarDetailObjTransferNum];
    self.engineNum = [aDecoder decodeObjectForKey:kCarDetailObjEngineNum];
    self.navigationCard = [aDecoder decodeObjectForKey:kCarDetailObjNavigationCard];
    self.envLevel = [aDecoder decodeObjectForKey:kCarDetailObjEnvLevel];
    self.issurLevel = [aDecoder decodeObjectForKey:kCarDetailObjIssurLevel];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeDouble:_internalBaseClassIdentifier forKey:kCarDetailObjId];
    [aCoder encodeObject:_gearType forKey:kCarDetailObjGearType];
    [aCoder encodeObject:_drivingLicenseTag forKey:kCarDetailObjDrivingLicenseTag];
    [aCoder encodeObject:_tripod forKey:kCarDetailObjTripod];
    [aCoder encodeObject:_facEqu forKey:kCarDetailObjFacEqu];
    [aCoder encodeObject:_maintenanceManual forKey:kCarDetailObjMaintenanceManual];
    [aCoder encodeObject:_envTag forKey:kCarDetailObjEnvTag];
    [aCoder encodeObject:_passengerNum forKey:kCarDetailObjPassengerNum];
    [aCoder encodeObject:_carColor forKey:kCarDetailObjCarColor];
    [aCoder encodeObject:_instruction forKey:kCarDetailObjInstruction];
    [aCoder encodeObject:_outputVolume forKey:kCarDetailObjOutputVolume];
    [aCoder encodeObject:_issurFee forKey:kCarDetailObjIssurFee];
    [aCoder encodeObject:_spareTire forKey:kCarDetailObjSpareTire];
    [aCoder encodeObject:_registMonth forKey:kCarDetailObjRegistMonth];
    [aCoder encodeObject:_marketDesc forKey:kCarDetailObjMarketDesc];
    [aCoder encodeObject:_licenseTag forKey:kCarDetailObjLicenseTag];
    [aCoder encodeObject:_licenseCode forKey:kCarDetailObjLicenseCode];
    [aCoder encodeObject:_checkValidDate forKey:kCarDetailObjCheckValidDate];
    [aCoder encodeObject:_upholsteryColor forKey:kCarDetailObjUpholsteryColor];
    [aCoder encodeObject:_cd forKey:kCarDetailObjCd];
    [aCoder encodeObject:_carKeys forKey:kCarDetailObjCarKeys];
    [aCoder encodeObject:_issurValidDate forKey:kCarDetailObjIssurValidDate];
    [aCoder encodeObject:_cusEqu forKey:kCarDetailObjCusEqu];
    [aCoder encodeObject:_factoryDate forKey:kCarDetailObjFactoryDate];
    [aCoder encodeObject:_vehicleType forKey:kCarDetailObjVehicleType];
    [aCoder encodeObject:_registNum forKey:kCarDetailObjRegistNum];
    [aCoder encodeObject:_mileageCount forKey:kCarDetailObjMileageCount];
    [aCoder encodeObject:_registTag forKey:kCarDetailObjRegistTag];
    [aCoder encodeObject:_purchaseTag forKey:kCarDetailObjPurchaseTag];
    [aCoder encodeObject:_maintenanceMile forKey:kCarDetailObjMaintenanceMile];
    [aCoder encodeObject:_invoiceTag forKey:kCarDetailObjInvoiceTag];
    [aCoder encodeObject:_usedType forKey:kCarDetailObjUsedType];
    [aCoder encodeObject:_transferNum forKey:kCarDetailObjTransferNum];
    [aCoder encodeObject:_engineNum forKey:kCarDetailObjEngineNum];
    [aCoder encodeObject:_navigationCard forKey:kCarDetailObjNavigationCard];
    [aCoder encodeObject:_envLevel forKey:kCarDetailObjEnvLevel];
    [aCoder encodeObject:_issurLevel forKey:kCarDetailObjIssurLevel];
}

- (id)copyWithZone:(NSZone *)zone
{
    CarDetailObj *copy = [[CarDetailObj alloc] init];
    
    if (copy) {

        copy.internalBaseClassIdentifier = self.internalBaseClassIdentifier;
        copy.gearType = [self.gearType copyWithZone:zone];
        copy.drivingLicenseTag = [self.drivingLicenseTag copyWithZone:zone];
        copy.tripod = [self.tripod copyWithZone:zone];
        copy.facEqu = [self.facEqu copyWithZone:zone];
        copy.maintenanceManual = [self.maintenanceManual copyWithZone:zone];
        copy.envTag = [self.envTag copyWithZone:zone];
        copy.passengerNum = [self.passengerNum copyWithZone:zone];
        copy.carColor = [self.carColor copyWithZone:zone];
        copy.instruction = [self.instruction copyWithZone:zone];
        copy.outputVolume = [self.outputVolume copyWithZone:zone];
        copy.issurFee = [self.issurFee copyWithZone:zone];
        copy.spareTire = [self.spareTire copyWithZone:zone];
        copy.registMonth = [self.registMonth copyWithZone:zone];
        copy.marketDesc = [self.marketDesc copyWithZone:zone];
        copy.licenseTag = [self.licenseTag copyWithZone:zone];
        copy.licenseCode = [self.licenseCode copyWithZone:zone];
        copy.checkValidDate = [self.checkValidDate copyWithZone:zone];
        copy.upholsteryColor = [self.upholsteryColor copyWithZone:zone];
        copy.cd = [self.cd copyWithZone:zone];
        copy.carKeys = [self.carKeys copyWithZone:zone];
        copy.issurValidDate = [self.issurValidDate copyWithZone:zone];
        copy.cusEqu = [self.cusEqu copyWithZone:zone];
        copy.factoryDate = [self.factoryDate copyWithZone:zone];
        copy.vehicleType = [self.vehicleType copyWithZone:zone];
        copy.registNum = [self.registNum copyWithZone:zone];
        copy.mileageCount = [self.mileageCount copyWithZone:zone];
        copy.registTag = [self.registTag copyWithZone:zone];
        copy.purchaseTag = [self.purchaseTag copyWithZone:zone];
        copy.maintenanceMile = [self.maintenanceMile copyWithZone:zone];
        copy.invoiceTag = [self.invoiceTag copyWithZone:zone];
        copy.usedType = [self.usedType copyWithZone:zone];
        copy.transferNum = [self.transferNum copyWithZone:zone];
        copy.engineNum = [self.engineNum copyWithZone:zone];
        copy.navigationCard = [self.navigationCard copyWithZone:zone];
        copy.envLevel = [self.envLevel copyWithZone:zone];
        copy.issurLevel = [self.issurLevel copyWithZone:zone];
    }
    
    return copy;
}


@end
